package com.sos.widget.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.sos.widget.R;

/**
 * @Description
 * @Author 梁浩文
 * @Date 2021/7/8 17:02
 */
public class CarNumView extends FrameLayout {
    EditText etCarLicenseInputbox1;
    EditText etCarLicenseInputbox2;
    EditText etCarLicenseInputbox3;
    EditText etCarLicenseInputbox4;
    EditText etCarLicenseInputbox5;
    EditText etCarLicenseInputbox6;
    EditText etCarLicenseInputbox7;
    EditText etCarLicenseInputbox8;
    public KeyboardFinish keyboardFinish;

    public void setKeyboardFinish(KeyboardFinish keyboardFinish) {
        this.keyboardFinish = keyboardFinish;
    }

    public CarNumView(@NonNull Context context) {
        super(context);
    }

    public CarNumView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View.inflate(getContext(), R.layout.view_car_num,this);
        etCarLicenseInputbox1=findViewById(R.id.et_car_license_inputbox1);
        etCarLicenseInputbox2=findViewById(R.id.et_car_license_inputbox2);
        etCarLicenseInputbox3=findViewById(R.id.et_car_license_inputbox3);
        etCarLicenseInputbox4=findViewById(R.id.et_car_license_inputbox4);
        etCarLicenseInputbox5=findViewById(R.id.et_car_license_inputbox5);
        etCarLicenseInputbox6=findViewById(R.id.et_car_license_inputbox6);
        etCarLicenseInputbox7=findViewById(R.id.et_car_license_inputbox7);
        etCarLicenseInputbox8=findViewById(R.id.et_car_license_inputbox8);
        EditText[] editTexts = {etCarLicenseInputbox1, etCarLicenseInputbox2, etCarLicenseInputbox3,
                etCarLicenseInputbox4, etCarLicenseInputbox5, etCarLicenseInputbox6, etCarLicenseInputbox7, etCarLicenseInputbox8};
        LicenseKeyboardUtil keyboardUtil = new LicenseKeyboardUtil(getContext(), this, editTexts, new LicenseKeyboardUtil.KeyboardFinish() {
            @Override
            public void carNumFinish() {
                if (keyboardFinish != null) {
                    keyboardFinish.carNumFinish();
                }
            }
        });
        keyboardUtil.showKeyboard();

    }

    public interface KeyboardFinish{
        void carNumFinish();
    }

}
